<%@page import="java.net.URLEncoder"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@page import="java.net.URLDecoder"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cookie的使用</title>
</head>
<body>
<%
	Cookie c=new Cookie("name",URLEncoder.encode("孙悟空", "GBK"));
	c.setMaxAge(24*60*60);
	response.addCookie(c);
	Cookie []ck=request.getCookies();
	for(Cookie ckie:ck){
		if(ckie.getName().equals("name")){
			out.print(java.net.URLDecoder.decode(ckie.getValue()));
		}
	}
%>
</body>
</html>